package cn.deali.homework9.adapter;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import java.util.ArrayList;

import cn.deali.homework9.activity.MainActivity;
import cn.deali.homework9.fragment.AlbumFragment;
import cn.deali.homework9.fragment.LocalMusicFragment;
import cn.deali.homework9.fragment.LyricFragment;
import cn.deali.homework9.fragment.OnlineMusicFragment;
import cn.deali.homework9.fragment.TopMusicListFragment;

public class MainViewPagerAdapter extends FragmentStatePagerAdapter {
    private ArrayList<Fragment> fragments;

    public MainViewPagerAdapter(Context context, @NonNull FragmentManager fm) {
        super(fm);
        fragments = new ArrayList<>();
        fragments.add(new LocalMusicFragment());
        fragments.add(new TopMusicListFragment(context));
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
